﻿using MediatR;
using S.EarTag.Domain.Model;
using S.EarTag.Infrastructure.Repository.Interface.IEarTagRepository;
using S.EarTag.Read.API.Mediator.MediatorCommand.MarkCommand;

namespace S.EarTag.Read.API.Mediator.MediatorCommandHandler.MarkCommandHandler
{
    public class MarkSeachStateCommandHandler : IRequestHandler<MarkSeachStateCommand, List<MarkModel>>
    {
        private readonly IMarkModelRepository _markModelRepository;
        public MarkSeachStateCommandHandler(IMarkModelRepository markModelRepository)
        {
            _markModelRepository= markModelRepository;
        }
        /// <summary>
        /// 查询修改电子耳标状态
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        /// <exception cref="NotImplementedException"></exception>
        public async Task<List<MarkModel>> Handle(MarkSeachStateCommand request, CancellationToken cancellationToken)
        {
            List<MarkModel> list= new List<MarkModel>();    
            if (request.MarkId == 0)
            {
                list = await _markModelRepository.GetMarkModels();
            }
            else
            {
                var result=await _markModelRepository.UpdDateMark(request.MarkId);
            }
            return list;
        }
    }
}
